package com.ruoyi.order.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.order.domain.SrvTickingform;
import com.ruoyi.order.service.ISrvTickingformService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 反馈单Controller
 * 
 * @author ruoyi
 * @date 2021-01-29
 */
@RestController
@RequestMapping("/tickingform")
public class SrvTickingformController extends BaseController
{
    @Autowired
    private ISrvTickingformService srvTickingformService;

    /**
     * 查询反馈单列表
     */
    @PreAuthorize(hasPermi = "system:tickingform:list")
    @GetMapping("/list")
    public TableDataInfo list(SrvTickingform srvTickingform)
    {
        startPage();
        List<SrvTickingform> list = srvTickingformService.selectSrvTickingformList(srvTickingform);
        return getDataTable(list);
    }

    /**
     * 导出反馈单列表
     */
    @PreAuthorize(hasPermi = "system:tickingform:export")
    @Log(title = "反馈单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SrvTickingform srvTickingform) throws IOException
    {
        List<SrvTickingform> list = srvTickingformService.selectSrvTickingformList(srvTickingform);
        ExcelUtil<SrvTickingform> util = new ExcelUtil<SrvTickingform>(SrvTickingform.class);
        util.exportExcel(response, list, "tickingform");
    }

    /**
     * 获取反馈单详细信息
     */
    @PreAuthorize(hasPermi = "system:tickingform:query")
    @GetMapping(value = "/{srvTfcode}")
    public AjaxResult getInfo(@PathVariable("srvTfcode") String srvTfcode)
    {
        return AjaxResult.success(srvTickingformService.selectSrvTickingformById(srvTfcode));
    }

    /**
     * 新增反馈单
     */
    @PreAuthorize(hasPermi = "system:tickingform:add")
    @Log(title = "反馈单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SrvTickingform srvTickingform)
    {
        return toAjax(srvTickingformService.insertSrvTickingform(srvTickingform));
    }

    /**
     * 修改反馈单
     */
    @PreAuthorize(hasPermi = "system:tickingform:edit")
    @Log(title = "反馈单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SrvTickingform srvTickingform)
    {
        return toAjax(srvTickingformService.updateSrvTickingform(srvTickingform));
    }

    /**
     * 删除反馈单
     */
    @PreAuthorize(hasPermi = "system:tickingform:remove")
    @Log(title = "反馈单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{srvTfcodes}")
    public AjaxResult remove(@PathVariable String[] srvTfcodes)
    {
        return toAjax(srvTickingformService.deleteSrvTickingformByIds(srvTfcodes));
    }
}
